package com.ruoyi.project.system.appsys.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.appsys.domain.AppSys;
import com.ruoyi.project.system.appsys.service.IAppSysService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 应用详细内容Controller
 * 
 * @author ruoyi
 * @date 2021-05-26
 */
@Controller
@RequestMapping("/system/appsys")
public class AppSysController extends BaseController
{
    private String prefix = "system/appsys";

    @Autowired
    private IAppSysService appSysService;

    @RequiresPermissions("system:appsys:view")
    @GetMapping()
    public String appsys()
    {
        return prefix + "/appsys";
    }

    /**
     * 查询应用详细内容列表
     */
    @RequiresPermissions("system:appsys:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AppSys appSys)
    {
        startPage();
        List<AppSys> list = appSysService.selectAppSysList(appSys);
        return getDataTable(list);
    }

    /**
     * 导出应用详细内容列表
     */
    @RequiresPermissions("system:appsys:export")
    @Log(title = "应用详细内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AppSys appSys)
    {
        List<AppSys> list = appSysService.selectAppSysList(appSys);
        ExcelUtil<AppSys> util = new ExcelUtil<AppSys>(AppSys.class);
        return util.exportExcel(list, "应用详细内容数据");
    }

    /**
     * 新增应用详细内容
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存应用详细内容
     */
    @RequiresPermissions("system:appsys:add")
    @Log(title = "应用详细内容", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AppSys appSys)
    {
        return toAjax(appSysService.insertAppSys(appSys));
    }

    /**
     * 修改应用详细内容
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AppSys appSys = appSysService.selectAppSysById(id);
        mmap.put("appSys", appSys);
        return prefix + "/edit";
    }

    /**
     * 修改保存应用详细内容
     */
    @RequiresPermissions("system:appsys:edit")
    @Log(title = "应用详细内容", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AppSys appSys)
    {
        return toAjax(appSysService.updateAppSys(appSys));
    }

    /**
     * 删除应用详细内容
     */
    @RequiresPermissions("system:appsys:remove")
    @Log(title = "应用详细内容", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(appSysService.deleteAppSysByIds(ids));
    }
}
